//==============================================================================
// SDL Tutorial 1
//==============================================================================
#ifndef _CAPP_H_
    #define _CAPP_H_

#include <SDL/SDL.h>

#include "CEvent.h"
#include "CSurface.h"

#include "LinuxSerialPort.h"
#include "Packet.h"
#include "PropertyPacket.h"
#include "LinuxRemoteProperty.h"

//==============================================================================
class CApp : public CEvent {
    private:
        bool            	Running;
        SDL_Surface*    	Surf_Display;
        SDL_Surface*		Surf_Test;

    	LinuxSerialPort 	mSerialPort;
    	Packet          	mPacket;
    	PropertyPacket  	mPropertyPacket;

    	LinuxRemoteProperty *mLeft;
    	LinuxRemoteProperty *mRight;
    	LinuxRemoteProperty *mLeftTarget;
    	LinuxRemoteProperty *mRightTarget;
    	LinuxRemoteProperty *mServoEnabled;
    	LinuxRemoteProperty *mServoPosition;
    	int mServoPositionCached;

    	bool mKeyUp;
    	bool mKeyDown;
    	bool mKeyLeft;
    	bool mKeyRight;

    	void updateSteppers();

    public:
        CApp();
        int OnExecute();

    public:
        bool OnInit();
        void OnEvent(SDL_Event* Event);
		void OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode);
        void OnKeyUp(SDLKey sym, SDLMod mod, Uint16 unicode);
        void OnMouseMove(int mX, int mY, int relX, int relY, bool Left,bool Right,bool Middle);
        void OnExit();
        void OnLoop();
        void OnRender();
        void OnCleanup();
};

//==============================================================================

#endif
